//
// Created by zzj on 2024/12/22.
//

#ifndef ANIMATIONUPDATEMANAGEMENT_PLATFORMRECORD_H
#define ANIMATIONUPDATEMANAGEMENT_PLATFORMRECORD_H

#include <ranges>
#include "SqliteDao.h"

class VideoPlatform final : public QObject {
    Q_OBJECT

public:
    VideoPlatform() = default;

    ~VideoPlatform() override = default;;

    template<std::ranges::input_range R>
    void InitVideoPlatforms(R &&range)
    {
        m_sqliteDao.InitDataBase();
        for (const auto ele: range) {
            SqliteDao::InitTable(ele);
        }
    }

    [[nodiscard]] static int GetSqlTotalCount(const QString &platformName);

    [[nodiscard]] static int GetSqlDayCount(const QString &tableName, const QString &dayOfWeekEnglish);

    static void AddAlreadyRead(const QString &tableName, int id);

    static QList<VideoPlatform *> VideoRecords(const QString &tableName, const QString &dayOfWeekEnglish);

    [[nodiscard]] int GetId() const;

    [[nodiscard]] QString GetUpdateTime() const;

    [[nodiscard]] QString GetPlayName() const;

    [[nodiscard]] int GetReadEpisode() const;

    [[nodiscard]] int GetUpdateEpisode() const;

    [[nodiscard]] int GetAllEpisode() const;

    [[nodiscard]] QMap<Qt::DayOfWeek, long long> GetDayOfWeek();

    [[nodiscard]] QString GetNote() const;

    void SetRecord(const tuple_record &tupleRecord);

    void UpdateRecord(const QString &tableName);

private:
    SqliteDao m_sqliteDao;
    int m_id{0};
    float m_updateTime{};
    QString m_playName{};
    int m_readEpisode{};
    int m_updateEpisode{};
    int m_allEpisode{};
    QMap<Qt::DayOfWeek, long long> m_dayOfWeekToLongMap{};
    QString m_note{};
};


#endif //ANIMATIONUPDATEMANAGEMENT_PLATFORMRECORD_H
